package com.whitlock.backend.util;

import com.whitlock.backend.entity.TKUser;
import org.apache.shiro.SecurityUtils;

/**
 * @author Whitlock
 * 用户工具类，获取登录用户相关信息
 * @date 2020/7/21   11:17 上午
 */
public class UserUtils {

    public static String getLoginUserId(){
        TKUser tkUser = (TKUser) SecurityUtils.getSubject().getPrincipal();
        return tkUser.getId();
    }

    public static String getLoginUserName(){
        TKUser tkUser = (TKUser) SecurityUtils.getSubject().getPrincipal();
        return tkUser.getUserName();
    }

    public static String getLoginOrgId(){
        TKUser tkUser = (TKUser) SecurityUtils.getSubject().getPrincipal();
        return tkUser.getOrgId();
    }

    public static TKUser getLoginUser(){
        TKUser tkUser = (TKUser) SecurityUtils.getSubject().getPrincipal();
        return tkUser;
    }
}
